import { PublicEntity } from "@entities/public.entity";
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity({
    name: 'sys_menu',
    orderBy: { sort: 'ASC' }
})
export class MenuEntity extends PublicEntity {
    @Column({ comment: '父级ID' })
    pid: number

    @Column({ comment: '菜单名称' })
    name: string

    @Column({ comment: '菜单类型（0.目录，1.页面，2.按钮）' })
    type: number

    @Column({ comment: '菜单路径' })
    path: string

    @Column({ comment: '菜单图标' })
    icon: string

    @Column({ comment: '权限标识编码，如：USER_QUERY', name: 'auth_code' })
    authCode: string

    @Column({ comment: '排序' })
    sort: number

    @Column({ comment: '使用终端，（0.PC， 1.H5）' })
    terminal: number

    @Column({ comment: '是否为外部连接，（0.否，1.是）', name: 'is_out_link' })
    isOutLink: number

    @Column({ comment: '是否可见，（0. 否，1.是）', name: 'is_visible' })
    isVisible: number

    @Column({ comment: '是否删除，（0.否，1.是）', name: 'is_delete', select: false })
    isDelete: number

    @Column({ comment: '备注', length: 100 })
    remark: string
}


/**
 * 菜单分组实体
 */
@Entity({
    name: 'sys_menu_group'
})
export class MenuGroupEntity extends PublicEntity {
    @Column({ comment: '分组名称', length: 30 })
    name: string

    @Column({comment: '分组描述', length: 50 })
    description: string
}


/**
 * 菜单分组菜单表
 */
@Entity({
    name: 'sys_menu_group_menus'
})
export class GroupMenus {
    @PrimaryColumn({ comment: '主键id'})
    id: number

    @Column({ name: 'menu_id', comment: '菜单id' })
    menuId: number

    @Column({ name: 'menu_group_id', comment: '分组id' })
    menuGroupId: number
}

